import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		/**
		 * 是否需要强制登录
		 */
		forcedLogin: false,
		hasLogin: false,
		user:{
			userName: "",
			token:"",
			index:0
		}
	},
	mutations: {
		login(state, myUser) {
			// state.userName = userName || '新用户';
			state.hasLogin = true;
			state.user.userName = myUser.userName || '新用户';
			state.user.token = myUser.token || ""
		},
		handClassIndex(state, index) {
			state.index = index;
		},
		logout(state) {
			state.userName = "";
			state.hasLogin = false;
		}
	}
})

export default store
